﻿using System.Linq.Expressions;

namespace WareHouse.Repositories.Repository
{
    public interface IRepository<TEntity> where TEntity : class, new()
    {
        /// <summary>
        /// 查单挑
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<TEntity> FirstAsync(Expression<Func<TEntity, bool>> expression);
        /// <summary>
        /// 查单挑
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<TEntity> FirstAsync();
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> InsertAsync(TEntity entity);
        /// <summary>
        /// 查全部
        /// </summary>
        /// <returns></returns>
        Task<List<TEntity>> QueryableAsync();
        /// <summary>
        /// 条件查
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<List<TEntity>> QueryableAsync(Expression<Func<TEntity, bool>> expression);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>

        Task<TEntity> UpdateAsync(TEntity entity);

        /// <summary>
        /// 物理删除+逻辑删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(TEntity entity);
    }
}